package sg.edu.nus.iss.phoenix.user.delegate;

import java.sql.SQLException;
import java.util.*;

import sg.edu.nus.iss.phoenix.user.entity.*;
import sg.edu.nus.iss.phoenix.user.service.*;
/**
 * 
 * @author Dinh Ngoc Vu
 *
 */
public class UserDelegate {
	
	private UserService service;

	public UserDelegate() {
		super();
		service = new UserService();
	}
	
	public void createUser(User userInput) throws SQLException{
		try {
			service.createUser(userInput);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			throw new SQLException("Cannot create an existing user!");			
		}
	}
	
	public void modifyUser(User userInput){
		service.modifyUser(userInput);
	}
	
	public void deleteUser(User userInput) throws SQLException{
		try {
			service.deleteUser(userInput);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			throw new SQLException("Cannot delete this user!");			
		}
	}
	
	public List<User> getAllUser(){
		List<User> listUsers = new ArrayList<User>();
		try{
			listUsers = service.getAllUser();
		}catch(Exception e){
			e.printStackTrace();
		}
		return listUsers;
	}
	
	public List<User> getAllPresenters() {
		List<User> presentersList = new ArrayList<User>();
		try {
			presentersList = (ArrayList<User>) service.getAllPresenters();	
		} 
		catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return presentersList;
	}

	public List<User> getAllProducers() {
		List<User> producersList = new ArrayList<User>();
		try {
			producersList = (ArrayList<User>) service.getAllProducers();	
		} 
		catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return producersList;
	}

	
	/*public User getUser(){
		return userService.getUser();
	}*/
}
